require "UIScrollBar_181219.lua" 

---- --发现错误即使把require注销掉也会导入文件
CLOSE_BUTTON_VISIBLITY_EVENT_NAME="KaleSimpleEventPhotoTake"
function initialize(scene)
  g_touchExtension = KuruTouchExtension.cast(KuruEngine.getInstance():getExtension("KuruTouch"))
  g_touchExtension:getTouchDownEvent():addEventHandler(onTouchDown)
  g_touchExtension:getTouchMoveEvent():addEventHandler(onTouchMove)
  g_touchExtension:getTouchUpEvent():addEventHandler(onTouchUp)
  g_eventExtension = KuruEventExtension.cast(KuruEngine.getInstance():getExtension("KuruEvent"))
  g_eventExtension:getSimpleEvent():addEventHandler(onSimpleEvent)
  --g_eventExtension:postSimpleEventToApp("KaleSimpleEventPhotoTake", "false")
 
  g_scrollBar = UIScrollBar:init(scene, 0.6)

  -- local curRes = KuruEngine.getInstance():getResolution()
  -- local curAspect = curRes.x / curRes.y --分辨率比例
  -- print("curAspect"..curRes.x..curRes.y)
  local config = KuruEngine.getInstance():getCameraConfig()
  aspectRatio = config:getAspectRatio()
  print("curAspect"..aspectRatio)
end

function onTouchDown(event)
  g_scrollBar:onTouchDown(event)
 --print("onTouchDown")
end

function onTouchMove(event)
  g_scrollBar:onTouchMove(event)
  --print("onTouchMove")
end

function onTouchUp(event)
  g_scrollBar:onTouchUp(event)
 -- print("onTouchUp")
end
function onSimpleEvent(event)
  local eventName = KuruEventExtensionSimpleEventArgs.cast(event):getName()
  g_eventExtension:postSimpleEventToApp("KaleSimpleEventPhotoTake", "false")
print("onSimpleEvent"..eventName)
end

function frameReady(scene, elapsedTime)
 print("frameReady"..g_scrollBar:getStrength())
 g_scrollBar:frameReady()
end
function onAspectRatioChanged(scene)
 
 -- local curRes = scene:getResolution()
  -- local rect = Rect:new(50,0,200,500,curRes)
  -- rect:setResolution(curRes)
  -- rect:transform(50,0,200,500,curRes)
  -- g_scrollBar:setRect(rect)

end
function finalize(scene)
  g_scrollBar:finalize()
  g_touchExtension:getTouchDownEvent():removeEventHandler(onTouchDown)
  g_touchExtension:getTouchMoveEvent():removeEventHandler(onTouchMove)
  g_touchExtension:getTouchUpEvent():removeEventHandler(onTouchUp)
  g_eventExtension:getSimpleEvent():removeEventHandler(onSimpleEvent)
end
function addNodeAndRelease(scene, node)
  scene:addNode(node)
  node:release()
  return node
end
